﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SWDataDB.BLL;
using SWDataDB.DAL;
using System.Data;

public partial class service_SpatialQuerySvc : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        if (Request.QueryString["method"] != null)
        {
            string strMethod = Request.QueryString["method"].ToString();
            if (strMethod == "GetAllInfo")
            {
                //Response.Write("[{name:'zhhw',age:'12'},{name:'zhhw1234',age:'13'}]");
                Response.Write(GetAllInfo());
                Response.End();
            }
            else if (strMethod == "GetInfoByRect")
            {
                double xmin = double.Parse(Request.QueryString["XMIN"].ToString());
                double ymin = double.Parse(Request.QueryString["YMIN"].ToString());
                double xmax = double.Parse(Request.QueryString["XMAX"].ToString());
                double ymax = double.Parse(Request.QueryString["YMAX"].ToString());
                SpaceQuery space = new SpaceQuery();
                Response.Write(GetInfoByRect(xmin, ymin, xmax, ymax));
                Response.End();
            }
        }
    }

    public string GetAllInfo()
    {
        ZLInfo zlobj = new ZLInfo();
        DataSet ds = new DataSet();

        ds = zlobj.GetAllInfoWithSet();

        return DataSet2Json.DataSetToJson(ds);
    }

    public string GetInfoByRect(double xmin, double ymin, double xmax, double ymax)
    {
        SpaceQuery space = new SpaceQuery();
        DataSet ds = space.ZLInfoSpaceQueryKC(xmin, ymin, xmax, ymax);

        return DataSet2Json.DataSetToJson(ds);
    }
}